﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Module.Core.LoginSystem.Commons.Framwork;
using Module.Core.LoginSystem.Components.Modules;


namespace Web.Cms.UserControls
{
    public partial class ModuleNavigator : AdminUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                List<ModuleDefinitionInfo> _moduleDefs = ModuleDefinitionController.GetModuleDefinitions(CurrentPortalID);
                foreach (ModuleDefinitionInfo _moduleDef in _moduleDefs)
                {
                    ComponentArt.Web.UI.NavBarItem _moduleDefItem = new ComponentArt.Web.UI.NavBarItem();
                    _moduleDefItem.Text = _moduleDef.Title;
                    _moduleDefItem.Value = _moduleDef.ModuleDefID.ToString();
                    //_moduleDefItem.SubGroupItemSpacing = 5;
                    _moduleDefItem.DefaultSubItemLookId = "Level2ItemLook";
                    _moduleDefItem.SubGroupCssClass = "Level2Group";
                    mnuSidebar.Items.Add(_moduleDefItem);
                    List<ModuleInfo> _modules = ModuleController.GetModules(_moduleDef.ModuleDefID);
                    foreach (ModuleInfo _module in _modules)
                    {
                        if (_module.CtrlKey != string.Empty)
                        {
                            ComponentArt.Web.UI.NavBarItem _moduleItem = new ComponentArt.Web.UI.NavBarItem();
                            _moduleItem.Text = _module.Title;
                            _moduleItem.Value = _module.CtrlKey;
                            _moduleItem.NavigateUrl = "/VietAnswer.Web.Giasoc/Cms/Default.aspx?ctrlkey=" + _module.CtrlKey;
                            _moduleDefItem.Items.Add(_moduleItem);
                        }
                    }
                }
            }
        }
    }
}